Title: SQL BT (By-BKK) / 17 Alter
Tags: Obsidian_to_Anki

Q: What SQL statement do you use to change an existing table’s structure?
A: ALTER TABLE

Q: How do you add a new column to a table in SQL?
A: Use ALTER TABLE table_name ADD column_name DataType

Q: True/False: You can use ALTER TABLE to remove columns in every SQL database
A: False. Not all databases support dropping columns

Q: How do you rename a table in SQL?
A: ALTER TABLE table_name RENAME TO new_table_name

Q: What does the DEFAULT value in ALTER TABLE do?
A: It sets a default value for existing and new rows

Q: What clause can place the new column at a specific position in some databases?
A: FIRST or AFTER (not standard, supported in MySQL)

Q: If you want to ensure a new column holds English as default language, what should you include?
A: DEFAULT 'English' in the column definition

Q: How do you remove a column in SQL if DROP is unsupported?
A: Create a new table with desired columns and migrate data

Q: Can you add constraints while altering a table?
A: Yes, constraints can be specified

Q: ALTER TABLE statement
What command is used to update a table’s structure in SQL?
A: Not all databases let you DROP columns directly
True/False: You can always use ALTER TABLE DROP to remove a column #flashcard

Q: ALTER TABLE … RENAME TO
How is a table renamed in SQL?
A: You can specify default values for new columns
What does DEFAULT do when adding a column with ALTER TABLE? #flashcard

Q: What statement is used to change the structure of an existing table?
A: ALTER TABLE

Q: How do you add a column to a table in SQL?
A: ALTER TABLE table_name ADD column_name DataType

Q: True/False: In all databases you can easily drop a column with ALTER TABLE
A: False

Q: How do you rename a table using SQL?
A: ALTER TABLE table_name RENAME TO new_table_name

Q: What does the DEFAULT keyword provide when adding a column?
A: Sets a default value for new and existing rows in that column

Q: How do you add a column at a specific position in MySQL?
A: Use FIRST or AFTER in ALTER TABLE

Q: What should you do in databases that don’t support DROP COLUMN?
A: Create a new table with new schema and migrate data

Q: Can you add constraints with ALTER TABLE when adding a column?
A: Yes

Q: Add a FLOAT column called Aspect_ratio to the Movies table
A: ALTER TABLE Movies ADD Aspect_ratio FLOAT

Q: Add a TEXT column called Language with default 'English' to the Movies table
A: ALTER TABLE Movies ADD Language TEXT DEFAULT 'English'

Q: What SQL command lets you change a table’s structure?
A: ALTER TABLE command

Q: What does DEFAULT do in ALTER TABLE ADD?
A: Set a default value for new columns with DEFAULT

Q: How can you add a column in a specific spot in MySQL?
A: FIRST and AFTER position columns, only in some databases like MySQL

Q: What should you do if ALTER TABLE DROP COLUMN isn’t supported?
A: Some databases may need to migrate data to drop a column

Q: How do you put a new column in a specific place in some SQL databases?
A: FIRST and AFTER can position columns, but are database-specific features